package com.redwood.report.adapter.bak;

import android.view.View;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.redwood.report.R;
import com.redwood.report.common.Constant;
import com.redwood.report.entity.bak.been.BaoXiuSearchBeen;
import com.redwood.report.entity.bak.been.ListBaoXiuBeen;
import com.redwood.report.entity.bak.been.ListWeiXiuBeen;
import com.redwood.report.util.Utils;

import java.util.List;

/**
 * 报修 维修 Adapter 未处理 处理中 已完成
 * Created by Supeng on 2018/8/23.
 */
//Caption been
public class WeiChuLiAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity,BaseViewHolder> {
    public static final int TYPE_LEVEL_BAOXIU = 0;
    public static final int TYPE_LEVEL_WEIXIU= 1;
    public   String chuliType= Constant.WEICHULI;
    public WeiChuLiAdapter(List data,String type) {
        super(data);
        addItemType(TYPE_LEVEL_BAOXIU, R.layout.layout_baoxiu_item);
        addItemType(TYPE_LEVEL_WEIXIU, R.layout.layout_weixiu_item);
        chuliType=type;
    }
    @Override
    protected void convert(final BaseViewHolder holder, MultiItemEntity itemTemp) {
        switch (holder.getItemViewType()) {
            case TYPE_LEVEL_BAOXIU:
                ListBaoXiuBeen baoXiuBeen= (ListBaoXiuBeen) itemTemp;
                BaoXiuSearchBeen baoXiuSearchBeen=baoXiuBeen.getBaoXiuSearchBeen();
                if(chuliType.equals(Constant.YICHULI)){
                    holder.getView(R.id.red_vv).setVisibility(View.GONE);
                    holder.getView(R.id.tv_chixvtimer).setVisibility(View.GONE);
                }else{
                    if(baoXiuSearchBeen.isHasRed()) {
                        holder.getView(R.id.red_vv).setVisibility(View.VISIBLE);
                    }else {
                        holder.getView(R.id.red_vv).setVisibility(View.INVISIBLE);
                    }
                    holder.getView(R.id.tv_chixvtimer).setVisibility(View.VISIBLE);
                }
                holder.setText(R.id.tv_gongdan_bianhao,baoXiuSearchBeen.getWxid());
                holder.setText(R.id.tv_bumen_name,"【"+baoXiuSearchBeen.getMacID()+baoXiuSearchBeen.getMacName()+"】");
                holder.setText(R.id.tv_neirong,"内容:"+baoXiuSearchBeen.getMtncContent());
                if(chuliType.equals(Constant.WEICHULI)) {
                    holder.setText(R.id.tv_shouliren, "报修人:" + baoXiuSearchBeen.getAppName());
                    holder.setText(R.id.tv_timer, Utils.timerParse(baoXiuSearchBeen.getAppTime()));
                    holder.setText(R.id.tv_chixvtimer,Utils.timerchixvParse(baoXiuSearchBeen.getAppTime()));
                }else{
                    holder.setText(R.id.tv_shouliren, "受理人:" + baoXiuSearchBeen.getRecName());
                    holder.setText(R.id.tv_timer, Utils.timerParse(baoXiuSearchBeen.getRecTime()));
                    holder.setText(R.id.tv_chixvtimer,Utils.timerchixvParse(baoXiuSearchBeen.getRecTime()));
                }
                break;
            case TYPE_LEVEL_WEIXIU:
                ListWeiXiuBeen weiXiuBeen= (ListWeiXiuBeen) itemTemp;
                BaoXiuSearchBeen weixiuSearchBeen=weiXiuBeen.getBaoXiuSearchBeen();
                if(chuliType.equals(Constant.YICHULI)){
                    holder.getView(R.id.red_vv).setVisibility(View.GONE);
                    holder.getView(R.id.tv_chixvtimer).setVisibility(View.GONE);
                }else{
                    if(weixiuSearchBeen.isHasRed()) {
                        holder.getView(R.id.red_vv).setVisibility(View.VISIBLE);
                    }else {
                        holder.getView(R.id.red_vv).setVisibility(View.INVISIBLE);
                    }
                    holder.getView(R.id.tv_chixvtimer).setVisibility(View.VISIBLE);
                }
                if("1".equals(weixiuSearchBeen.getKind())) {
                    holder.setText(R.id.tv_type, "维修");
                }else if("2".equals(weixiuSearchBeen.getKind())){
                    holder.setText(R.id.tv_type, "巡检");
                }else if("3".equals(weixiuSearchBeen.getKind())){
                    holder.setText(R.id.tv_type, "保养");
                }
                holder.setText(R.id.tv_gongdan_bianhao,weixiuSearchBeen.getWxid());
                holder.setText(R.id.tv_bumen_name,"【"+weixiuSearchBeen.getMacID()+weixiuSearchBeen.getMacName()+"】");
                holder.setText(R.id.tv_neirong,"内容:"+weixiuSearchBeen.getMtncContent());
                if(chuliType.equals(Constant.WEICHULI)) {
                    holder.setText(R.id.tv_shouliren, "报修人:" + weixiuSearchBeen.getAppName());
                    holder.setText(R.id.tv_timer, Utils.timerParse(weixiuSearchBeen.getAppTime()));
                    holder.setText(R.id.tv_chixvtimer,Utils.timerchixvParse(weixiuSearchBeen.getAppTime()));
                }else{
                    holder.setText(R.id.tv_shouliren, "受理人:" + weixiuSearchBeen.getRecName());
                    holder.setText(R.id.tv_timer, Utils.timerParse(weixiuSearchBeen.getRecTime()));
                    holder.setText(R.id.tv_chixvtimer,Utils.timerchixvParse(weixiuSearchBeen.getRecTime()));
                }
                break;
        }

    }
}
